package cn.wpp;


/*
 * 同步线程的两种方式
 * 第一种是实现
 *
 *
 *
 * */
class test2 extends Thread {
    private static int taket = 100;

    @Override
    public void run() {
        while (true) {
            synchronized (test2.class) {
                if (taket > 0) {
                    System.out.println(Thread.currentThread().getName() + ":" + taket);
                }
                taket--;

            }
        }
    }
}


public class SnychronizedExtent {
    public static void main(String args[]) {
        test2 test1 = new test2();
        test2 test2 = new test2();
        test2 test3 = new test2();

        test1.start();
        test2.start();
        test3.start();
    }

}
